﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace PyramidShadow
{
    /*
     * Holds  textfield.
     * Important: I don't check for dimensions. The string which goes as paramter needs to be formated allready:
     * To be safe: Max 60 chars a row and max 40 rows!
     */
    class TextField
    {
        private Vector2 linePos;
        private Texture2D bg_texture;
        private Rectangle position;
        private String[] text;
        private SpriteFont font;

        public TextField(String[] txt,SpriteFont font,Texture2D bg_texture) 
        {
            this.font = font;
            this.text = txt;
            this.bg_texture = bg_texture;
            int longestLine = 0;
            for (int i = 0; i < text.Length; i++)
            
            {
                if (text[i].Length > longestLine)
                    longestLine = text[i].Length;
            }

            position = new Rectangle(10, 10, longestLine * (int)font.Spacing, text.Length * font.LineSpacing);
            linePos = new Vector2(position.X, position.Y);
        }

        public void draw(SpriteBatch spriteBatch)
        {
            for(int i = 0; i < text.Length;i++)
            {
                spriteBatch.DrawString(font,text[i],linePos,Color.White);
                linePos.Y += font.LineSpacing;
            }
        }
    }
}
